/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package conceitos.DAO;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import javax.swing.JOptionPane;

/**
 *
 * @author jeferson
 */
public class JogoDAO {
    private Connection conexao;

    public JogoDAO() {
        conexao = Conexao.getInstance();
    }
    
    public boolean salvarPontuacao(int idAmbiente, int idConta, int pontuacaoAluno, int statusAmbiente){
        String sql = "update contaambientes set pontuacaoaluno = ?, statusconta = ? where idconta = "+idConta+" AND idambiente = "+idAmbiente;
        try {
            PreparedStatement ps = conexao.prepareStatement(sql);
            ps.setInt(1, pontuacaoAluno);
            ps.setInt(2, statusAmbiente);
            int retorno = ps.executeUpdate();
            conexao.commit();
            if (retorno > 0) {            
                return true;
            }
        } catch (SQLException ex) {
            ex.printStackTrace();
            JOptionPane.showMessageDialog(null, "Erro: " + ex.getMessage());
        }
        return false;
    }
        
}
